package com.ycz.algorithm.utils.queue;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author yancz
 * @ClassName QueueUtil
 * @description: TODO
 * @date 2024-11-21 16:51:42
 * @version: 1.0
 */
public class QueueUtil {

    public static void main(String[] args) {
        // 队列初始化
        Queue<Integer> queue = new LinkedList<>();
        // 入队
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        queue.offer(4);
        queue.offer(5);
        for (int i : queue) {
            System.out.print(i + "\t");
        }
        System.out.println();
        System.out.println("队首元素：" + queue.peek());
        // 元素出队
        int num = queue.poll();
        System.out.println("出队元素：" + num);
        for (int i : queue) {
            System.out.print(i + "\t");
        }
        System.out.println();
        System.out.println("队列长度：" + queue.size());
        System.out.println("是否队空：" + queue.isEmpty());
    }

}
